#ifndef __MY_LOG_UTIL__
#define __MY_LOG_UTIL__
#include<iostream>
#include<ctime>
#include<sys/stat.h>
#include<sys/types.h>
#include<string>
#include<cstring>
namespace mylog
{
    namespace Util
    {
        class Date{
            private:


            public:
                static size_t GetTime()
                {
                    return (size_t)time(nullptr);
                }
        };

        class File{
            private:

            public:
            static bool Exists(const std::string& pathname)
            {
                struct stat st;
                if(stat(pathname.c_str(),&st) < 0)
                {
                    return false;
                }
                return true;
            }
            static std::string path(const std::string& pathname)
            {
                size_t pos = pathname.find_last_of("\\/");
                if(pos == pathname.npos)
                {
                    return ".";
                }
                return pathname.substr(0,pos+1);
            }
            static bool CreateDirector(const std::string& pathname)
            {
                size_t pos = 0;
                int prev = 0;
                do
                {
                    pos = pathname.find_first_of("\\/",prev);
                    if(Exists(pathname.substr(0,pos)) == false)
                    {
                        if(mkdir(pathname.substr(0,pos).c_str(),0777) == -1)
                        {
                            std::cout << "CreateDirector ERR" << strerror(errno) << std::endl;
                            return false;
                        }
                    }
                    prev = pos+1;
                } while(pos != pathname.npos);
                return true;
            }
        };
    }
}


#endif